
if exists (select 1 from sysobjects where name = 'get_activemonths' and type = 'P')
begin
   drop procedure get_activemonths
   print 'Procedure: get_activemonths deleted ...'
end
go
create procedure get_activemonths(
  @mandid             char(2)           = 'li'
)
as
begin
  set nocount on

  select jahrid = pj.JahrID,
         jahr = Jahr,
         name = Name,
         von = at.Von,
         bis = at.Bis,
         atid = ATID,
         tage = Tage,
         typwert = typwert
    from PlanungsJahr pj
   inner join ArbeitsTage at
      on at.JahrID = pj.JahrID
   where pj.mandid = @mandid
     and pj.Status = 1
     and at.typ = 1

end
go
print 'Procedure: get_activemonths done ...'
go
grant exec on get_activemonths to prsadmins with grant option
go
grant exec on get_activemonths to prsusers
go

